package com.marvels.loanapply.api.impl;

import com.marvels.common.constants.MarvelsConstant;
import com.marvels.common.utils.CacheUtils;
import com.marvels.loanapply.api.RelationInfoApi;
import com.marvels.loanapply.dao.MclaRelationInfoDao;
import com.marvels.loanapply.dto.MclaRelationInfoDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RelationInfoImpl implements RelationInfoApi{

	
	@Autowired
	private MclaRelationInfoDao relationDao;
	
	@Override
	public List<MclaRelationInfoDTO> relationList(MclaRelationInfoDTO dto) {
		List<MclaRelationInfoDTO> list = relationDao.relationList(dto);
		Object object=CacheUtils.getCacheObject(MarvelsConstant.RELATION_SHIP);
		if(null!=object){
			list=(List<MclaRelationInfoDTO>)object;
		}
		if(CollectionUtils.isEmpty(list)){
			list=relationDao.relationList(dto);
			CacheUtils.cacheObject(MarvelsConstant.RELATION_SHIP, list);
		}
		return list;
	}
	
	
}
